package com.xiangban.controller;

import com.xiangban.aop.Permission;
import com.xiangban.model.UserAccompany;
import com.xiangban.model.dto.UserAccompanyDto;
import com.xiangban.model.res.ApiResult;
import com.xiangban.model.res.Ids;
import com.xiangban.service.AccompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/12/2 14:15
 */
@RestController
@RequestMapping("/accompany")
@Api(tags = "陪诊信息")
public class AccompanyController {

    @Autowired
    private AccompanyService accompanyService;


    @RequestMapping("/AuditAccompany")
    @ApiOperation("审核陪诊员")
    @Permission(permission = "admin:accompany:AuditAccompany")
    //master、slave
    public ApiResult<Object> AuditAccompany(@RequestBody UserAccompany userAccompany) {
        accompanyService.AuditAccompany(userAccompany);
        return ApiResult.newSuccess();
    }

    @RequestMapping("/listAccompanyPage")
    @ApiOperation("列表陪诊员信息")
    @Permission(permission = "admin:accompany:listAccompanyPage")
    //master、slave
    public ApiResult<Object> listAccompanyPage(@RequestBody UserAccompanyDto userAccompanyDto) {
        return ApiResult.newSuccess(accompanyService.listAccompanyPage(userAccompanyDto));
    }

    @RequestMapping("/updateAccompany")
    @ApiOperation("修改陪诊员信息")
    @Permission(permission = "admin:accompany:updateAccompany")
    //master、slave
    public ApiResult<Object> updateAccompany(@RequestBody UserAccompanyDto userAccompanyDto) {
        accompanyService.updateAccompany(userAccompanyDto);
        return ApiResult.newSuccess();
    }

    @RequestMapping("/getAccompany")
    @ApiOperation("详情陪诊员信息")
    @Permission(permission = "admin:accompany:getAccompany")
    //master、slave
    public ApiResult<Object> getAccompany(@RequestBody UserAccompany userAccompany) {
        return ApiResult.newSuccess(accompanyService.getAccompany(userAccompany));
    }

    @RequestMapping("/removeAccompany")
    @ApiOperation("删除陪诊员信息")
    @Permission(permission = "admin:accompany:removeAccompany")
    //master、slave
    public ApiResult<Object> removeAccompany(@RequestBody Ids ids) {
        accompanyService.removeAccompany(ids);
        return ApiResult.newSuccess();
    }

}
